home *** CD-ROM | disk | FTP | other *** search
- package javax.swing;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.Insets;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.io.IOException;
- import java.io.ObjectOutputStream;
- import java.util.Vector;
- import javax.accessibility.Accessible;
- import javax.accessibility.AccessibleContext;
- import javax.swing.event.ListSelectionEvent;
- import javax.swing.event.ListSelectionListener;
- import javax.swing.plaf.ListUI;
-
- public class JList extends JComponent implements Scrollable, Accessible {
- private static final String uiClassID = "ListUI";
- private int fixedCellWidth;
- private int fixedCellHeight;
- private int horizontalScrollIncrement;
- private Object prototypeCellValue;
- private int visibleRowCount;
- private Color selectionForeground;
- private Color selectionBackground;
- private ListSelectionModel selectionModel;
- private ListModel dataModel;
- private ListCellRenderer cellRenderer;
- private ListSelectionListener selectionListener;
- // $FF: synthetic field
- static Class class$javax$swing$event$ListSelectionListener;
-
- public JList() {
- this((ListModel)(new 3()));
- }
-
- public JList(Vector var1) {
- this((ListModel)(new 2(var1)));
- }
-
- public JList(ListModel var1) {
- this.fixedCellWidth = -1;
- this.fixedCellHeight = -1;
- this.horizontalScrollIncrement = -1;
- this.visibleRowCount = 8;
- if (var1 == null) {
- throw new IllegalArgumentException("dataModel must be non null");
- } else {
- this.dataModel = var1;
- this.selectionModel = this.createSelectionModel();
- ((JComponent)this).setAutoscrolls(true);
- ((JComponent)this).setOpaque(true);
- this.updateUI();
- }
- }
-
- public JList(Object[] var1) {
- this((ListModel)(new 1(var1)));
- }
-
- // $FF: synthetic method
- static ListSelectionModel access$0(JList var0) {
- return var0.selectionModel;
- }
-
- public void addListSelectionListener(ListSelectionListener var1) {
- if (this.selectionListener == null) {
- this.selectionListener = new ListSelectionHandler(this);
- this.getSelectionModel().addListSelectionListener(this.selectionListener);
- }
-
- super.listenerList.add(class$javax$swing$event$ListSelectionListener != null ? class$javax$swing$event$ListSelectionListener : (class$javax$swing$event$ListSelectionListener = class$("javax.swing.event.ListSelectionListener")), var1);
- }
-
- public void addSelectionInterval(int var1, int var2) {
- this.getSelectionModel().addSelectionInterval(var1, var2);
- }
-
- // $FF: synthetic method
- static Class class$(String var0) {
- try {
- return Class.forName(var0);
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
- }
-
- public void clearSelection() {
- this.getSelectionModel().clearSelection();
- }
-
- protected ListSelectionModel createSelectionModel() {
- return new DefaultListSelectionModel();
- }
-
- public void ensureIndexIsVisible(int var1) {
- Rectangle var2 = this.getCellBounds(var1, var1);
- if (var2 != null) {
- ((JComponent)this).scrollRectToVisible(var2);
- }
-
- }
-
- protected void fireSelectionValueChanged(int var1, int var2, boolean var3) {
- Object[] var4 = super.listenerList.getListenerList();
- ListSelectionEvent var5 = null;
-
- for(int var6 = var4.length - 2; var6 >= 0; var6 -= 2) {
- if (var4[var6] == (class$javax$swing$event$ListSelectionListener != null ? class$javax$swing$event$ListSelectionListener : (class$javax$swing$event$ListSelectionListener = class$("javax.swing.event.ListSelectionListener")))) {
- if (var5 == null) {
- var5 = new ListSelectionEvent(this, var1, var2, var3);
- }
-
- ((ListSelectionListener)var4[var6 + 1]).valueChanged(var5);
- }
- }
-
- }
-
- public AccessibleContext getAccessibleContext() {
- if (super.accessibleContext == null) {
- super.accessibleContext = new AccessibleJList(this);
- }
-
- return super.accessibleContext;
- }
-
- public int getAnchorSelectionIndex() {
- return this.getSelectionModel().getAnchorSelectionIndex();
- }
-
- public Rectangle getCellBounds(int var1, int var2) {
- ListUI var3 = this.getUI();
- return var3 != null ? var3.getCellBounds(this, var1, var2) : null;
- }
-
- public ListCellRenderer getCellRenderer() {
- return this.cellRenderer;
- }
-
- public int getFirstVisibleIndex() {
- Point var1 = ((JComponent)this).getVisibleRect().getLocation();
- return this.locationToIndex(var1);
- }
-
- public int getFixedCellHeight() {
- return this.fixedCellHeight;
- }
-
- public int getFixedCellWidth() {
- return this.fixedCellWidth;
- }
-
- public int getLastVisibleIndex() {
- Rectangle var1 = ((JComponent)this).getVisibleRect();
- Point var2 = new Point(var1.x + var1.width - 1, var1.y + var1.height - 1);
- return this.locationToIndex(var2);
- }
-
- public int getLeadSelectionIndex() {
- return this.getSelectionModel().getLeadSelectionIndex();
- }
-
- public int getMaxSelectionIndex() {
- return this.getSelectionModel().getMaxSelectionIndex();
- }
-
- public int getMinSelectionIndex() {
- return this.getSelectionModel().getMinSelectionIndex();
- }
-
- public ListModel getModel() {
- return this.dataModel;
- }
-
- public Dimension getPreferredScrollableViewportSize() {
- Insets var1 = ((JComponent)this).getInsets();
- int var2 = var1.left + var1.right;
- int var3 = var1.top + var1.bottom;
- int var4 = this.getVisibleRowCount();
- int var5 = this.getFixedCellWidth();
- int var6 = this.getFixedCellHeight();
- if (var5 > 0 && var6 > 0) {
- int var12 = var5 + var2;
- int var13 = var4 * var6 + var3;
- return new Dimension(var12, var13);
- } else if (this.getModel().getSize() > 0) {
- int var7 = ((JComponent)this).getPreferredSize().width;
- Rectangle var8 = this.getCellBounds(0, 0);
- int var9 = var4 * var8.height + var3;
- return new Dimension(var7, var9);
- } else {
- var5 = var5 > 0 ? var5 : 256;
- var6 = var6 > 0 ? var6 : 16;
- return new Dimension(var5, var6 * var4);
- }
- }
-
- public Object getPrototypeCellValue() {
- return this.prototypeCellValue;
- }
-
- public int getScrollableBlockIncrement(Rectangle var1, int var2, int var3) {
- return var2 == 1 ? var1.height : var1.width;
- }
-
- public boolean getScrollableTracksViewportHeight() {
- if (((Component)this).getParent() instanceof JViewport) {
- return ((JViewport)((Component)this).getParent()).getHeight() > ((JComponent)this).getPreferredSize().height;
- } else {
- return false;
- }
- }
-
- public boolean getScrollableTracksViewportWidth() {
- if (((Component)this).getParent() instanceof JViewport) {
- return ((JViewport)((Component)this).getParent()).getWidth() > ((JComponent)this).getPreferredSize().width;
- } else {
- return false;
- }
- }
-
- public int getScrollableUnitIncrement(Rectangle var1, int var2, int var3) {
- if (var2 == 0) {
- Font var7 = ((Component)this).getFont();
- return var7 != null ? var7.getSize() : 1;
- } else {
- int var4 = this.getFirstVisibleIndex();
- if (var4 == -1) {
- return 0;
- } else if (var3 > 0) {
- Rectangle var8 = this.getCellBounds(var4, var4);
- return var8 == null ? 0 : var8.height - (var1.y - var8.y);
- } else {
- Rectangle var5 = this.getCellBounds(var4, var4);
- if (var5.y == var1.y && var4 == 0) {
- return 0;
- } else if (var5.y == var1.y) {
- Rectangle var6 = this.getCellBounds(var4 - 1, var4 - 1);
- return var6 == null ? 0 : var6.height;
- } else {
- return var1.y - var5.y;
- }
- }
- }
- }
-
- public int getSelectedIndex() {
- return this.getMinSelectionIndex();
- }
-
- public int[] getSelectedIndices() {
- ListSelectionModel var1 = this.getSelectionModel();
- int var2 = var1.getMinSelectionIndex();
- int var3 = var1.getMaxSelectionIndex();
- if (var2 >= 0 && var3 >= 0) {
- int[] var4 = new int[1 + (var3 - var2)];
- int var5 = 0;
-
- for(int var6 = var2; var6 <= var3; ++var6) {
- if (var1.isSelectedIndex(var6)) {
- var4[var5++] = var6;
- }
- }
-
- int[] var7 = new int[var5];
- System.arraycopy(var4, 0, var7, 0, var5);
- return var7;
- } else {
- return new int[0];
- }
- }
-
- public Object getSelectedValue() {
- int var1 = this.getMinSelectionIndex();
- return var1 == -1 ? null : this.getModel().getElementAt(var1);
- }
-
- public Object[] getSelectedValues() {
- ListSelectionModel var1 = this.getSelectionModel();
- ListModel var2 = this.getModel();
- int var3 = var1.getMinSelectionIndex();
- int var4 = var1.getMaxSelectionIndex();
- if (var3 >= 0 && var4 >= 0) {
- Object[] var5 = new Object[1 + (var4 - var3)];
- int var6 = 0;
-
- for(int var7 = var3; var7 <= var4; ++var7) {
- if (var1.isSelectedIndex(var7)) {
- var5[var6++] = var2.getElementAt(var7);
- }
- }
-
- Object[] var8 = new Object[var6];
- System.arraycopy(var5, 0, var8, 0, var6);
- return var8;
- } else {
- return new Object[0];
- }
- }
-
- public Color getSelectionBackground() {
- return this.selectionBackground;
- }
-
- public Color getSelectionForeground() {
- return this.selectionForeground;
- }
-
- public int getSelectionMode() {
- return this.getSelectionModel().getSelectionMode();
- }
-
- public ListSelectionModel getSelectionModel() {
- return this.selectionModel;
- }
-
- public ListUI getUI() {
- return (ListUI)super.ui;
- }
-
- public String getUIClassID() {
- return "ListUI";
- }
-
- public boolean getValueIsAdjusting() {
- return this.getSelectionModel().getValueIsAdjusting();
- }
-
- public int getVisibleRowCount() {
- return this.visibleRowCount;
- }
-
- public Point indexToLocation(int var1) {
- ListUI var2 = this.getUI();
- return var2 != null ? var2.indexToLocation(this, var1) : null;
- }
-
- public boolean isSelectedIndex(int var1) {
- return this.getSelectionModel().isSelectedIndex(var1);
- }
-
- public boolean isSelectionEmpty() {
- return this.getSelectionModel().isSelectionEmpty();
- }
-
- public int locationToIndex(Point var1) {
- ListUI var2 = this.getUI();
- return var2 != null ? var2.locationToIndex(this, var1) : -1;
- }
-
- protected String paramString() {
- String var1 = this.selectionForeground != null ? this.selectionForeground.toString() : "";
- String var2 = this.selectionBackground != null ? this.selectionBackground.toString() : "";
- return super.paramString() + ",fixedCellHeight=" + this.fixedCellHeight + ",fixedCellWidth=" + this.fixedCellWidth + ",horizontalScrollIncrement=" + this.horizontalScrollIncrement + ",selectionBackground=" + var2 + ",selectionForeground=" + var1 + ",visibleRowCount=" + this.visibleRowCount;
- }
-
- public void removeListSelectionListener(ListSelectionListener var1) {
- super.listenerList.remove(class$javax$swing$event$ListSelectionListener != null ? class$javax$swing$event$ListSelectionListener : (class$javax$swing$event$ListSelectionListener = class$("javax.swing.event.ListSelectionListener")), var1);
- }
-
- public void removeSelectionInterval(int var1, int var2) {
- this.getSelectionModel().removeSelectionInterval(var1, var2);
- }
-
- public void setCellRenderer(ListCellRenderer var1) {
- ListCellRenderer var2 = this.cellRenderer;
- this.cellRenderer = var1;
- if (var1 != null && !var1.equals(var2)) {
- this.updateFixedCellSize();
- }
-
- ((JComponent)this).firePropertyChange("cellRenderer", var2, var1);
- }
-
- public void setFixedCellHeight(int var1) {
- int var2 = this.fixedCellHeight;
- this.fixedCellHeight = var1;
- ((JComponent)this).firePropertyChange("fixedCellHeight", var2, this.fixedCellHeight);
- }
-
- public void setFixedCellWidth(int var1) {
- int var2 = this.fixedCellWidth;
- this.fixedCellWidth = var1;
- ((JComponent)this).firePropertyChange("fixedCellWidth", var2, this.fixedCellWidth);
- }
-
- public void setListData(Vector var1) {
- this.setModel(new 5(var1));
- }
-
- public void setListData(Object[] var1) {
- this.setModel(new 4(var1));
- }
-
- public void setModel(ListModel var1) {
- if (var1 == null) {
- throw new IllegalArgumentException("model must be non null");
- } else {
- ListModel var2 = this.dataModel;
- this.dataModel = var1;
- ((JComponent)this).firePropertyChange("model", var2, this.dataModel);
- this.clearSelection();
- }
- }
-
- public void setPrototypeCellValue(Object var1) {
- Object var2 = this.prototypeCellValue;
- this.prototypeCellValue = var1;
- if (var1 != null && !var1.equals(var2)) {
- this.updateFixedCellSize();
- }
-
- ((JComponent)this).firePropertyChange("prototypeCellValue", var2, var1);
- }
-
- public void setSelectedIndex(int var1) {
- this.getSelectionModel().setSelectionInterval(var1, var1);
- }
-
- public void setSelectedIndices(int[] var1) {
- ListSelectionModel var2 = this.getSelectionModel();
- var2.clearSelection();
-
- for(int var3 = 0; var3 < var1.length; ++var3) {
- var2.addSelectionInterval(var1[var3], var1[var3]);
- }
-
- }
-
- public void setSelectedValue(Object var1, boolean var2) {
- if (var1 == null) {
- this.setSelectedIndex(-1);
- } else if (!var1.equals(this.getSelectedValue())) {
- ListModel var5 = this.getModel();
- int var3 = 0;
-
- for(int var4 = var5.getSize(); var3 < var4; ++var3) {
- if (var1.equals(var5.getElementAt(var3))) {
- this.setSelectedIndex(var3);
- if (var2) {
- this.ensureIndexIsVisible(var3);
- }
-
- ((Component)this).repaint();
- return;
- }
- }
-
- this.setSelectedIndex(-1);
- }
-
- ((Component)this).repaint();
- }
-
- public void setSelectionBackground(Color var1) {
- Color var2 = this.selectionBackground;
- this.selectionBackground = var1;
- ((JComponent)this).firePropertyChange("selectionBackground", var2, var1);
- }
-
- public void setSelectionForeground(Color var1) {
- Color var2 = this.selectionForeground;
- this.selectionForeground = var1;
- ((JComponent)this).firePropertyChange("selectionForeground", var2, var1);
- }
-
- public void setSelectionInterval(int var1, int var2) {
- this.getSelectionModel().setSelectionInterval(var1, var2);
- }
-
- public void setSelectionMode(int var1) {
- this.getSelectionModel().setSelectionMode(var1);
- }
-
- public void setSelectionModel(ListSelectionModel var1) {
- if (var1 == null) {
- throw new IllegalArgumentException("selectionModel must be non null");
- } else {
- if (this.selectionListener != null) {
- this.selectionModel.removeListSelectionListener(this.selectionListener);
- var1.addListSelectionListener(this.selectionListener);
- }
-
- ListSelectionModel var2 = this.selectionModel;
- this.selectionModel = var1;
- ((JComponent)this).firePropertyChange("selectionModel", var2, var1);
- }
- }
-
- public void setUI(ListUI var1) {
- super.setUI(var1);
- }
-
- public void setValueIsAdjusting(boolean var1) {
- this.getSelectionModel().setValueIsAdjusting(var1);
- }
-
- public void setVisibleRowCount(int var1) {
- int var2 = this.visibleRowCount;
- this.visibleRowCount = Math.max(0, var1);
- ((JComponent)this).firePropertyChange("visibleRowCount", var2, var1);
- }
-
- private void updateFixedCellSize() {
- ListCellRenderer var1 = this.getCellRenderer();
- Object var2 = this.getPrototypeCellValue();
- if (var1 != null && var2 != null) {
- Component var3 = var1.getListCellRendererComponent(this, var2, 0, false, false);
- Font var4 = var3.getFont();
- var3.setFont(((Component)this).getFont());
- Dimension var5 = var3.getPreferredSize();
- this.fixedCellWidth = var5.width;
- this.fixedCellHeight = var5.height;
- var3.setFont(var4);
- }
-
- }
-
- public void updateUI() {
- this.setUI((ListUI)UIManager.getUI(this));
- ((Container)this).invalidate();
- }
-
- private void writeObject(ObjectOutputStream var1) throws IOException {
- var1.defaultWriteObject();
- if (super.ui != null && this.getUIClassID().equals("ListUI")) {
- super.ui.installUI(this);
- }
-
- }
- }
-